#include<bits/stdc++.h>
using namespace std;

const int N = 200100;
int a[N],c[N],n,y[N];
int T,ans=0;

void dfs(int x){
    if(x==n){
        int sum=0;
        for(int i=0;i<n;i++){
            for(int j=i-1;j>=0;j--){
                if(y[j]==y[i]){
                    if(a[j]==a[i]){
                        sum+=a[i];
                        //cout<<i<<" "<<a[i]<<" "<<sum<<endl;
                       // cout<<endl;
                    }
                    break;
                }
            }
        }
        ans=max(ans,sum);
       // cout<<endl<<endl<<endl;
        return ;
    }
    else{
        for(int i=0;i<2;i++){
            y[x]=i;
            dfs(x+1);
        }
    }
}

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);

    cin>>T;
    while(T--){
        cin>>n;
        memset(y,0x3f,sizeof(y));
        for(int i=0;i<n;i++)cin>>a[i];
        dfs(0);
        cout<<ans<<endl;
        ans=0;

    }
    return 0;
}
